﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.EnterpriseServices;
using com.IronOne.SLIC2.Models.Job;
using com.IronOne.SLIC2.Models.Reports;
using com.IronOne.SLIC2.Models.Enums;
using log4net;
using com.IronOne.SLIC2.Models.EntityModel;
using com.IronOne.IronUtils;
using com.IronOne.SLIC2.Models.Administration;
using com.IronOne.SLIC2.Lang;
using com.IronOne.SLIC2.HandlerClasses;

namespace com.IronOne.SLIC2.Controllers
{
    /// <summary>
    ///  <title></title>
    ///  <description></description>
    ///  <copyRight>Copyright (c) 2012</copyRight>
    ///  <company>IronOne Technologies (Pvt)Ltd</company>
    ///  <createdOn>2012-mm-dd</createdOn>
    ///  <author></author>
    ///  <modification>
    ///     <modifiedBy></modifiedBy>
    ///      <modifiedDate></modifiedDate>
    ///     <description></description>
    ///  </modification>
    /// </summary>
    public class ReportController : BaseController
    {
        protected static readonly ILog logevt = LogManager.GetLogger("EventLog");
        protected static readonly ILog logerr = LogManager.GetLogger("ErrorLog");

        #region Actions

        /// <summary>
        ///  <description>The Index Action</description>
        ///  <param></param>
        ///  <returns>
        ///  </returns>       
        ///  <exception>
        ///  </exception>
        ///  <remarks></remarks>
        /// </summary>
        // GET: /Report/

        [Description("Index")]
        public ActionResult Index()
        {
            return View();
        }

        [Description("Audit Log")]
        public ActionResult AuditLog(AccessLogModel searchModel)
        {
            List<SelectListItem> branchList = new List<SelectListItem>();
            branchList.Add(new SelectListItem
            {
                Text = Resources.info_gen_all,
                Value = "-1",
                Selected = true
            });

            if (!string.IsNullOrEmpty(searchModel.RegionName))
            {
                if (!searchModel.RegionName.Equals("-1"))
                {
                    try
                    {
                        List<SelectListItem> initBranchList = new List<SelectListItem>();
                        using (MotorClaimEntities context = DataObjectFactory.CreateContext())
                        {
                            IEnumerable<vw_Branches> query = from b in context.vw_Branches
                                                             where b.RegionName == searchModel.RegionName
                                                             select b;
                            initBranchList = (from b in query
                                              orderby b.BranchName
                                              select new SelectListItem
                                              {
                                                  Text = b.BranchName,
                                                  Value = b.BranchName
                                              }).ToList();
                            branchList.AddRange(initBranchList);
                        }
                    }
                    catch (Exception)
                    { }
                }
            }

            ViewData["Branches"] = branchList;

            List<SelectListItem> regionList = new List<SelectListItem>();
            regionList.Add(new SelectListItem
            {
                Text = Resources.info_gen_all,
                Value = "-1",
                Selected = true
            });
            regionList.AddRange(ConvertRegionsToSelectListForAuditLog(JobController.GetRegionDataList()));
            ViewData["Regions"] = regionList;

            List<SelectListItem> InspectionTypeList = new List<SelectListItem>();
            InspectionTypeList.Add(new SelectListItem
            {
                Text = Resources.info_gen_all,
                Value = "-1",
                Selected = true
            });

            //List<KeyValuePair<int, string>> lst = new List<KeyValuePair<int, string>>();
            //foreach (Enum val in Enum.GetValues(typeof(VisitType)))
            //{
            //    int key = Convert.ToInt32(val);
            //    string value = val.ToString();
            //    lst.Add(new KeyValuePair<int, string>(key, value));
            //}
            //InspectionTypeList.AddRange(ConvertToTextSelectList(lst));
            InspectionTypeList.AddRange(ConvertToTextSelectList(EnumUtils.GetEnumList(typeof(VisitType))));
          
            ViewData["InspectionType"] = InspectionTypeList;

            return GetFormatView("Reports/AuditLogs.aspx", searchModel);
        }

        [Description("Visit Log")]
        public ActionResult VisitLog(int? ID)
        {
            if (ID.HasValue)
            {
                return GetFormatView("Reports/VisitLogs.aspx", ID);
            }
            else
            {
                return ErrorView();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="regionName"></param>
        /// <returns></returns>
        [HttpPost]
        [Description("Find Branches By Region Id")]
        public JsonResult FindBranchesByRegionId(string regionName)
        {
            try
            {
                List<BranchDataModel> branches = new List<BranchDataModel>();

                using (MotorClaimEntities context = DataObjectFactory.CreateContext())
                {
                    IEnumerable<vw_Branches> query = from b in context.vw_Branches
                                                      where b.RegionName == regionName
                                                      select b;
                    branches.Add(new BranchDataModel
                    {
                        BranchName = Resources.info_gen_all,
                        BranchId = -1
                    });
                    branches.AddRange((from b in query
                                orderby b.BranchName
                                select new BranchDataModel
                                {
                                    BranchName = b.BranchName,
                                    RegionId = b.RegionId,
                                    BranchId = b.BranchId
                                }).ToList());
                }
                JsonResult result = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet };

                result.Data = branches;

                return result;
            }
            catch (Exception e)
            {
                logerr.Error(LogPoint.Failure.ToString() + "," + this.ControllerContext.Controller.ToString() + ",On FindBranchesByRegionId," + User.Identity.Name + ","+e.Message+ ",Stack Trace:" + e.StackTrace);
               
                return new JsonResult
                {
                    Data = Resources.err_901
                };
            }
        }

        [Description("Audit Log Ajax Handler")]
        public ActionResult AuditLogAjaxHandler(JQueryDataTableParamModel param, AccessLogModel searchModel)
        {
            int totalRecordCount = 0;
            List<String[]> jsonData = new List<string[]>();

            var isModuleSearchable = Convert.ToBoolean(Request["bSearchable_0"]);
            var isActionSearchable = Convert.ToBoolean(Request["bSearchable_1"]);
            var isAccessTypeSearchable = Convert.ToBoolean(Request["bSearchable_2"]);
            var isAccessIPSearchable = Convert.ToBoolean(Request["bSearchable_3"]);
            var isUserNameSearchable = Convert.ToBoolean(Request["bSearchable_4"]);
            var isRefIDSearchable = Convert.ToBoolean(Request["bSearchable_5"]);
            var isEventStatusSearchable = Convert.ToBoolean(Request["bSearchable_6"]);
            var isDateSearchable = Convert.ToBoolean(Request["bSearchable_7"]);
            var isDescriptionSearchable = Convert.ToBoolean(Request["bSearchable_8"]);
            var isParamsSearchable = Convert.ToBoolean(Request["bSearchable_9"]);

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            string orderingColomn = "Date";
            DateTime? dateFrom = searchModel.DateFrom;
            DateTime? dateTo = searchModel.DateTo;

            if (searchModel.DateFrom.HasValue && searchModel.TimeFrom.HasValue)
            {
                dateFrom = searchModel.DateFrom.Value + (searchModel.TimeFrom.Value - DateTime.Today);
            }
            if (searchModel.DateTo.HasValue && searchModel.TimeTo.HasValue)
            {
                dateTo = searchModel.DateTo.Value + (searchModel.TimeTo.Value - DateTime.Today);
            }

            switch (sortColumnIndex)
            {
                case 0:
                    orderingColomn = "Date";
                    break;
                case 1:
                    orderingColomn = "VehicleNo";
                    break;
                case 2:
                    orderingColomn = "JobNo";
                    break;
                case 3:
                    orderingColomn = "CSRCode";
                    break;
                case 4:
                    orderingColomn = "Username";
                    break;
                case 5:
                    orderingColomn = "BranchName";
                    break;
                case 6:
                    orderingColomn = "InspectionType";
                    break;
                case 7:
                    orderingColomn = "Action";
                    break;
                default:
                    orderingColomn = "Date";
                    break;
            }

            List<KeyValuePair<string, string>[]> eventList = auditLogger.GetEvents(string.Empty, string.Empty, string.Empty, string.Empty, searchModel.Username, string.Empty, dateFrom.HasValue ? dateFrom.Value : DateTime.Now.AddYears(-1), dateTo, string.Empty, string.Empty, searchModel.CSRCode, searchModel.BranchName.Equals("-1") ? string.Empty : searchModel.BranchName.ToString(), searchModel.RegionName.Equals("-1") ? string.Empty : searchModel.RegionName.ToString(), searchModel.EFPNo, searchModel.VehicleNo, searchModel.JobNo, searchModel.InspectionTypeName.Equals("-1") ? string.Empty : searchModel.InspectionTypeName.ToString(), string.Empty, string.Empty, string.Empty, orderingColomn, Request["sSortDir_0"] == null ? true : Request["sSortDir_0"].Equals("desc") ? true : false, param.iDisplayStart, param.iDisplayLength, out totalRecordCount);

            #region Searching Section

            //eventList = (from j in eventList
            //             where (searchModel.ModuleName != null ? j[6].Value.ToLower().Contains(searchModel.ModuleName.ToLower()) : true) &&
            //             (searchModel.ActionName != null ? j[7].Value.ToLower().Contains(searchModel.ActionName.ToLower()) : true) &&
            //             (searchModel.AccessType == null || searchModel.AccessType.Equals("-1") ? true : j[8].Value.ToLower().Contains(searchModel.AccessType.ToLower())) &&
            //             (searchModel.AccessIP != null ? j[9].Value.ToLower().Contains(searchModel.AccessIP.ToLower()) : true) &&
            //             (searchModel.UserName != null ? j[5].Value.ToLower().Contains(searchModel.UserName.ToLower()) : true) &&
            //             (searchModel.RefID != 0 ? j[3].Value.Equals(searchModel.RefID) : true) &&
            //             (searchModel.EventStatus != null || searchModel.EventStatus.Equals("-1") ? true : j[1].Value.ToLower().Contains(searchModel.EventStatus.ToLower())) &&
            //             (searchModel.DateFrom.HasValue ? DateTime.Parse(j[4].Value) > searchModel.DateFrom : true) &&
            //             (searchModel.DateTo.HasValue ? DateTime.Parse(j[4].Value) < searchModel.DateTo : true) &&
            //             (searchModel.Description != null ? j[2].Value.ToLower().Contains(searchModel.Description.ToLower()) : true) &&
            //             (searchModel.Params != null ? j[10].Value.ToLower().Contains(searchModel.Params.ToLower()) : true)
            //             select j).ToList();

            //if (!String.IsNullOrEmpty(param.sSearch))
            //{
            //    eventList =
            //        eventList.Where(
            //            r => isModuleSearchable && r[6].Value.ToLower().Contains(param.sSearch.ToLower())
            //                 ||
            //                 isActionSearchable && r[7].Value.ToLower().Contains(param.sSearch.ToLower())
            //                ||
            //                isAccessTypeSearchable && r[8].Value.ToLower().Contains(param.sSearch.ToLower())
            //                 ||
            //                 isAccessIPSearchable && r[9].Value.ToLower().Contains(param.sSearch.ToLower())
            //                ||
            //                isUserNameSearchable && r[5].Value.ToLower().Contains(param.sSearch.ToLower())
            //                ||
            //                isRefIDSearchable && r[3].Value.ToLower().Contains(param.sSearch.ToLower())
            //                ||
            //                isEventStatusSearchable && r[1].Value.ToLower().Contains(param.sSearch.ToLower())
            //                 ||
            //                 isDateSearchable &&
            //                 r[4].Value.ToLower().Contains(param.sSearch.ToLower())
            //                ||
            //                isDescriptionSearchable && r[2].Value.ToLower().Contains(param.sSearch.ToLower())
            //                ||
            //                isParamsSearchable && r[10].Value.ToLower().Contains(param.sSearch.ToLower())
            //            ).ToList();
            //}

            #endregion

            #region Sorting Section

            //var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            //int orderingIndex = 0;

            //switch (sortColumnIndex)
            //{
            //    case 0:
            //        orderingIndex = 6;
            //        break;
            //    case 1:
            //        orderingIndex = 7;
            //        break;
            //    case 2:
            //        orderingIndex = 8;
            //        break;
            //    case 3:
            //        orderingIndex = 9;
            //        break;
            //    case 4:
            //        orderingIndex = 5;
            //        break;
            //    case 5:
            //        orderingIndex = 3;
            //        break;
            //    case 6:
            //        orderingIndex = 1;
            //        break;
            //    case 7:
            //        orderingIndex = 4;
            //        break;
            //    case 8:
            //        orderingIndex = 2;
            //        break;
            //    case 9:
            //        orderingIndex = 2;
            //        break;
            //    default:
            //        orderingIndex = 0;
            //        break;
            //}

            //var sortDirection = Request["sSortDir_0"]; // asc or desc
            //if (sortDirection == "asc")
            //    eventList = eventList.OrderBy(c => c[orderingIndex].Value).ToList();
            //else
            //    eventList = eventList.OrderByDescending(c => c[orderingIndex].Value).ToList();

            #endregion

            foreach (KeyValuePair<string, string>[] item in eventList)
            {
                string[] eventRow = new string[9];
                eventRow[0] = DateTime.Parse(item[8].Value).ToString(ApplicationSettings.GetDateTimeFormat); //Date
                eventRow[1] = item[15].Value; //GEN_VehicleNo
                eventRow[2] = item[16].Value; //JobNo
                eventRow[3] = item[11].Value; //Code
                eventRow[4] = item[5].Value; //UserName
                eventRow[5] = item[12].Value; //Branch
                eventRow[6] = item[17].Value; //InspectionType
                eventRow[7] = item[2].Value; //Action
                //eventRow[7] = item[7].Value;
                //eventRow[8] = item[8].Value;
                //eventRow[9] = item[9].Value;
                //eventRow[10] = item[10].Value;
                jsonData.Add(eventRow);
            }

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecordCount,
                iTotalDisplayRecords = totalRecordCount,
                aaData = jsonData
            },
JsonRequestBehavior.AllowGet);
        }

        [Description("Visit Log Ajax Handler")]
        public ActionResult VisitLogAjaxHandler(JQueryDataTableParamModel param, int ID)
        {
            int totalRecordCount = 0;
            List<String[]> jsonData = new List<string[]>();

            var isModuleSearchable = Convert.ToBoolean(Request["bSearchable_0"]);
            var isActionSearchable = Convert.ToBoolean(Request["bSearchable_1"]);
            var isAccessTypeSearchable = Convert.ToBoolean(Request["bSearchable_2"]);
            var isAccessIPSearchable = Convert.ToBoolean(Request["bSearchable_3"]);
            var isUserNameSearchable = Convert.ToBoolean(Request["bSearchable_4"]);
            var isRefIDSearchable = Convert.ToBoolean(Request["bSearchable_5"]);
            var isEventStatusSearchable = Convert.ToBoolean(Request["bSearchable_6"]);
            var isDateSearchable = Convert.ToBoolean(Request["bSearchable_7"]);
            var isDescriptionSearchable = Convert.ToBoolean(Request["bSearchable_8"]);
            var isParamsSearchable = Convert.ToBoolean(Request["bSearchable_9"]);

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            string orderingColomn = "Date";

            switch (sortColumnIndex)
            {
                case 0:
                    orderingColomn = "Date";
                    break;
                case 1:
                    orderingColomn = "VehicleNo";
                    break;
                case 2:
                    orderingColomn = "JobNo";
                    break;
                case 3:
                    orderingColomn = "CSRCode";
                    break;
                case 4:
                    orderingColomn = "Username";
                    break;
                case 5:
                    orderingColomn = "BranchName";
                    break;
                case 6:
                    orderingColomn = "InspectionType";
                    break;
                case 7:
                    orderingColomn = "Action";
                    break;
                default:
                    orderingColomn = "Date";
                    break;
            }

            List<KeyValuePair<string, string>[]> eventList = auditLogger.GetEvents(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, DateTime.Now.AddYears(-1), null, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, ID.ToString(), string.Empty, string.Empty, orderingColomn, Request["sSortDir_0"] == null ? true : Request["sSortDir_0"].Equals("desc") ? true : false, param.iDisplayStart, param.iDisplayLength, out totalRecordCount);

            foreach (KeyValuePair<string, string>[] item in eventList)
            {
                string[] eventRow = new string[9];
                eventRow[0] = DateTime.Parse(item[8].Value).ToString(ApplicationSettings.GetDateTimeFormat); //Date
                eventRow[1] = item[15].Value; //GEN_VehicleNo
                eventRow[2] = item[16].Value; //JobNo
                eventRow[3] = item[11].Value; //Code
                eventRow[4] = item[5].Value; //UserName
                eventRow[5] = item[12].Value; //Branch
                eventRow[6] = item[17].Value; //InspectionType
                eventRow[7] = item[2].Value; //Action
                //eventRow[7] = item[7].Value;
                //eventRow[8] = item[8].Value;
                //eventRow[9] = item[9].Value;
                //eventRow[10] = item[10].Value;
                jsonData.Add(eventRow);
            }

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecordCount,
                iTotalDisplayRecords = totalRecordCount,
                aaData = jsonData
            },
JsonRequestBehavior.AllowGet);
        }

        [Description("Download AuditLog as Excel")]
        public FileContentResult AuditLogToExcel(AccessLogModel searchModel)
        {
            try
            {
                logevt.Info(LogPoint.Entry.ToString() + "," + this.ControllerContext.Controller.ToString() + ",AuditLog To Excel," + User.Identity.Name);

                using (MotorClaimEntities context = DataObjectFactory.CreateContext())
                {
                    int rowCount = 0;
                    DateTime? dateFrom = searchModel.DateFrom;
                    DateTime? dateTo = searchModel.DateTo;

                    if (searchModel.DateFrom.HasValue && searchModel.TimeFrom.HasValue)
                    {
                        dateFrom = searchModel.DateFrom.Value + (searchModel.TimeFrom.Value - DateTime.Today);
                    }
                    if (searchModel.DateTo.HasValue && searchModel.TimeTo.HasValue)
                    {
                        dateTo = searchModel.DateTo.Value + (searchModel.TimeTo.Value - DateTime.Today);
                    }

                    List<KeyValuePair<string, string>[]> events = auditLogger.GetEvents(string.Empty, string.Empty, string.Empty, string.Empty, searchModel.Username, string.Empty, dateFrom.HasValue ? dateFrom.Value : DateTime.Now.AddYears(-1), dateTo, string.Empty, string.Empty, searchModel.CSRCode, searchModel.BranchName.Equals("-1") ? string.Empty : searchModel.BranchName.ToString(), searchModel.RegionName.Equals("-1") ? string.Empty : searchModel.RegionName.ToString(), searchModel.EFPNo, searchModel.VehicleNo, searchModel.JobNo, searchModel.InspectionTypeName.Equals("-1") ? string.Empty : searchModel.InspectionTypeName.ToString(), string.Empty, string.Empty, string.Empty, "", true, 1, 65535, out rowCount);
                    List<KeyValuePair<string, string>[]> filteredData = new List<KeyValuePair<string, string>[]>();

                    foreach (KeyValuePair<string, string>[] item in events)
                    {
                        filteredData.Add(new KeyValuePair<string, string>[] { 
                            new KeyValuePair<string,string>("Vehicle No", item[15].Value),
                            new KeyValuePair<string,string>("Job No", item[16].Value),
                            new KeyValuePair<string,string>("CSR Code", item[11].Value),
                            new KeyValuePair<string,string>("User Name", item[5].Value),
                            new KeyValuePair<string,string>("Branch", item[12].Value),
                            new KeyValuePair<string,string>("Inspection Type", item[17].Value),
                            new KeyValuePair<string,string>("Action", item[2].Value)
                        });
                    }
                    byte[] fileContent = ConverterUtils.DataListToExcel(filteredData);

                    if (fileContent != null)
                    {
                        logevt.Info(LogPoint.Success.ToString() + "," + this.ControllerContext.Controller.ToString() + ",AuditLog To Excel," + User.Identity.Name);
                        auditLogger.AddEvent(LogPoint.Success.ToString());
                        return File(fileContent, "text/csv", "AuditLog_Excel_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".csv");
                    }
                }
            }
            catch (GenException ex)
            {
                logerr.Error(LogPoint.Failure.ToString() + "," + this.ControllerContext.Controller.ToString() + ",AuditLog To Excel," + User.Identity.Name + "," + ex.Message + ",Stack Trace:" + ex.StackTrace);
            }
            catch (Exception ex)
            {
                logerr.Error(LogPoint.Failure.ToString() + "," + this.ControllerContext.Controller.ToString() + ",AuditLog To Excel," + User.Identity.Name + "," + ex.Message + ",Stack Trace:" + ex.StackTrace);
            }
            return null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        [Description("Audit Log Print Preview")]
        public ActionResult AuditLogPrintPreview(AccessLogModel searchModel)
        {
            List<AccessLogModel> data = new List<AccessLogModel>();
            try
            {
                logevt.Info(LogPoint.Entry.ToString() + "," + this.ControllerContext.Controller.ToString() + ",Audit Log Print Preview," + User.Identity.Name + ",[Params=(Job No:" + searchModel.JobNo + ",Vehicle No:" + searchModel.VehicleNo + ")]");

                using (MotorClaimEntities context = DataObjectFactory.CreateContext())
                {
                    int rowCount = 0;
                    DateTime? dateFrom = searchModel.DateFrom;
                    DateTime? dateTo = searchModel.DateTo;

                    if (searchModel.DateFrom.HasValue && searchModel.TimeFrom.HasValue)
                    {
                        dateFrom = searchModel.DateFrom.Value + (searchModel.TimeFrom.Value - DateTime.Today);
                    }
                    if (searchModel.DateTo.HasValue && searchModel.TimeTo.HasValue)
                    {
                        dateTo = searchModel.DateTo.Value + (searchModel.TimeTo.Value - DateTime.Today);
                    }

                    List<KeyValuePair<string, string>[]> events = auditLogger.GetEvents(string.Empty, string.Empty, string.Empty, string.Empty, searchModel.Username, string.Empty, dateFrom.HasValue ? dateFrom.Value : DateTime.Now.AddYears(-1), dateTo, string.Empty, string.Empty, searchModel.CSRCode, searchModel.BranchName.Equals("-1") ? string.Empty : searchModel.BranchName.ToString(), searchModel.RegionName.Equals("-1") ? string.Empty : searchModel.RegionName.ToString(), searchModel.EFPNo, searchModel.VehicleNo, searchModel.JobNo, searchModel.InspectionTypeName.Equals("-1") ? string.Empty : searchModel.InspectionTypeName.ToString(), string.Empty, string.Empty, string.Empty, "", true, 1, 65535, out rowCount);

                    foreach (KeyValuePair<string, string>[] item in events)
                    {
                        data.Add(new AccessLogModel()
                        {
                            VehicleNo = item[15].Value,
                            JobNo = item[16].Value,
                            CSRCode = item[11].Value,
                            Username = item[5].Value,
                            BranchName = item[12].Value,
                            InspectionTypeName = item[17].Value,
                            Action = item[2].Value
                        });
                    }

                    TempData["searchModel"] = searchModel;

                    logevt.Info(LogPoint.Success.ToString() + "," + this.ControllerContext.Controller.ToString() + ",Audit Log Print Preview," + User.Identity.Name + ",[Params=(Job No:" + searchModel.JobNo + ",Vehicle No:" + searchModel.VehicleNo + ")]");
                    auditLogger.AddEvent(LogPoint.Success.ToString());
                }

                //Used for the footer
                ViewData["PrintUser"] = GetUser();
            }
            catch (GenException e)
            {
                ModelState.AddModelError("err", e);
                logerr.Error(LogPoint.Failure.ToString() + "," + this.ControllerContext.Controller.ToString() + ",Audit Log Print Preview," + User.Identity.Name + "," + e.Message + ",Stack Trace:" + e.StackTrace);
            }
            catch (Exception e)
            {
                ModelState.AddModelError("err", new GenException(600, Resources.err_600));
                logerr.Error(LogPoint.Failure.ToString() + "," + this.ControllerContext.Controller.ToString() + ",Audit Log Print Preview," + User.Identity.Name + "," + e.Message + ",Stack Trace:" + e.StackTrace);
            }
            return GetFormatView("Reports/PrintAuditLogs.aspx", data);
        }

        #endregion

        #region NonActions
        #endregion
    }
}
